package gui;
/**
 * Example of a Fenetre (JFrame) using awt and swing
 * @author your_name
 */

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Fenetre extends JFrame implements ActionListener {

	/** a label for the name */
	private JLabel label;
	/** a textfield for the name */
	private JTextField text;
	/** a button to perform an action: e.g. say hello (TBD) */
	private JButton button;
	/** a label for the hello + name */
	private JLabel helloText;

	/** Creates a Fenetre */
	public Fenetre() {
		initComponents();
	}

	/** Initializes the Fenetre components */

	private void initComponents() {
		// create the components
		// a new label with the "Nom" as value
		label = new JLabel("Nom: ");
		// a new text field with 20 columns
		text = new JTextField(20);
		// a new button identified as OK
		button = new JButton("OK");
		button.addActionListener(this);
		//a new text area for the hello text
		this.helloText = new JLabel();
		// configures the JFrame layout using a border layout
		this.setLayout(new BorderLayout());
		// places the components in the layout
		this.add("West",label);
		this.add("Center",text);
		this.add("East",button);
		this.add("South",helloText);
		// packs the fenetre: size is calculated
		// regarding the added components
		this.pack();
		// the JFrame is visible now
		this.setVisible(true);
	}

	/** main entry point */
	public static void main(String[] args) {
		Fenetre f = new Fenetre();
		f.setDefaultCloseOperation(Fenetre.EXIT_ON_CLOSE);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		helloText.setText("Hola senor(a) : " + this.text.getText());
		this.pack();
	}
}